package Test.Test1;

public class Market {
    String marketName;
    String address;
    Member []members=new Member[100];
    //添加新会员开卡
    public boolean addmember(Member member) {
        for (int i = 0; i < members.length; i++) {
            if (members[i] != null && members[i].cardNumber.equals(member)) {
                return false;
            } else if (members[i] == null) {
                members[i] = member;
                return true;
            }
        }
        return false;
    }
    //涨分
    public boolean  inc(String cardNo,int fen){
        for (int i=0;i<members.length;i++){
            if (members[i]!=null&&members[i].cardNumber.equals(cardNo)){
                members[i].jifen=members[i].jifen+fen;
                System.out.println("涨分后用户的积分是"+members[i].jifen);
                return true;
            }
        }
        System.out.println("卡号错误，没有该会员");
        return false;
    }
    //换购商品
    public String duihuan(String cardNo,int lipingleixing){
        for (int i=0;i<members.length;i++){
            if (members[i]!=null&&members[i].cardNumber.equals(cardNo)){
                switch (lipingleixing){
                    case 1:
                        if (members[i].jifen>=100){
                            members[i].jifen-=100;
                            System.out.println("兑换100积分成功后剩余积分"+members[i].jifen);
                            return "100分兑换餐巾纸一包";
                        }else{
                            return null;
                        }
                    case 2:if (members[i].jifen>=400){
                        members[i].jifen-=400;
                        System.out.println("兑换400积分成功后剩余积分"+members[i].jifen);
                        return "400积分兑换剃须刀一把";
                    }else {
                        return null;
                    }
                    case 3:if (members[i].jifen>=1000){
                        members[i].jifen-=1000;
                        System.out.println("兑换1000积分成功后剩余积分"+members[i].jifen);
                        return "1000积分兑换炒锅一个";
                    }else{
                        return null;
                    }
                    }
                }
            }
            return null;
        }
        //商场信息
    public void show(){
        System.out.println("商场名字是"+marketName+"\n商场地址是"+address);
    }
    }

